/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.commonmultithread.thread;

import java.util.concurrent.CountDownLatch;

/**
 * class info
 *
 * @author hujia
 * @date 2018/11/23 10:13
 */
public class SynchronizedIncrement implements Runnable {
    private static int number = 0;
    private final CountDownLatch count;

    public SynchronizedIncrement(CountDownLatch count) {
        this.count = count;
    }

    @Override
    public void run() {
        for (int j = 0; j < 1000; j++) {
            synchronized (this) {
                number++;
                System.out.println(Thread.currentThread().getName() + ":the number is " + number);
            }
        }
        count.countDown();
    }
}
